﻿<%@ Page Title="Shopping Cart" Language="C#" MasterPageFile="~/account/account.master"
    AutoEventWireup="true" CodeFile="Shoppingcart.aspx.cs" Inherits="account_Shoppingcart" %>

<asp:Content ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .shopGroup
        {
            border: 3px solid brown;
            padding: 0.5em 5px;
            margin-top: 1em;
        }
        
        .shopGroup .shopName
        {
            margin: 0;
        }
        
        #summary
        {
            display: table;
            width: 100%;
            margin-top: 1em;
        }
        
        #summary > *
        {
            display: table-cell;
            text-align: right;
        }
        
        .shopGroup table
        {
         width:100%;   
        }
        
        #totalPrice
        {
            min-width: 400px;
            width: 60%;
            font-weight:bold;
        }
        
        #payButton
        {
            margin-left: 50px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="AccountContent" runat="Server">
    <section>
        <asp:LinqDataSource ID="cartItemsSource" runat="server" OnSelecting="cartItemsSource_Selecting"
            OnDeleting="cartItemsSource_Deleting" />
        <asp:HiddenField ID="productIdsField" ClientIDMode="Static" runat="server" />
        <asp:Repeater ID="shopRepeater" runat="server" DataSourceID="cartItemsSource">
            <%--        <asp:DataList ID="DataList1" runat="server" DataSourceID="cartItemsSource">--%>
            <ItemTemplate>
                <section class="shopGroup">
                    <h3 class="shopName">
                        Shop: <a href='<%# Eval("Key","../Shop.aspx?n={0}") %>'>
                            <%# Eval("Key") %></a>
                    </h3>
                    <asp:GridView ID="GridView1" runat="server" DataSource='<%# Eval("It") %>' AutoGenerateColumns="False"
                        DataKeyNames="ProductId" CaptionAlign="Left" HeaderStyle-BorderStyle="None" FooterStyle-BorderStyle="None"
                        EditRowStyle-BorderStyle="None" GridLines="None" OnRowDeleting="deleteCartItem">
                        <Columns>
                            <asp:BoundField DataField="coverPhoto" SortExpression="coverPhoto" />
                            <asp:HyperLinkField DataNavigateUrlFields="ProductId" HeaderText="Product Name" DataNavigateUrlFormatString="../product.aspx?id={0}"
                                DataTextField="ProductName" />
                            <asp:BoundField DataField="ProductDiscountedPrice" HeaderText="Price" SortExpression="Price"
                                DataFormatString="{0:.00}">
                                <HeaderStyle HorizontalAlign="Left" />
                            </asp:BoundField>
                            <asp:BoundField DataField="Quantity" HeaderText="Quantity" SortExpression="Quantity">
                                <HeaderStyle HorizontalAlign="Left" />
                            </asp:BoundField>
                            <asp:TemplateField HeaderText="Subtotal">
                                <ItemTemplate>
                                    <%#  (Convert.ToSingle(Eval("ProductDiscountedPrice")) * Convert.ToInt32(Eval("quantity"))).ToString(".##")%>
                                </ItemTemplate>
                                <HeaderStyle HorizontalAlign="Left" />
                            </asp:TemplateField>
                            <asp:CommandField ButtonType="Button" ShowDeleteButton="True" />
                        </Columns>
                        <EditRowStyle BorderStyle="None" />
                        <FooterStyle BorderStyle="None" />
                        <HeaderStyle BorderStyle="None" HorizontalAlign="Left" />
                    </asp:GridView>
                </section>
            </ItemTemplate>
            <%--        </asp:DataList>--%>
        </asp:Repeater>
    </section>
    <section id="summary">
        <div id="totalPrice">
            Total <span>$<asp:Label ID="totalPriceLabel" runat="server" /></span>
        </div>
        <asp:Button ID="payButton" runat="server" Text="Pay" ClientIDMode="Static" 
        onclick="payButton_Click" />
    </section>
</asp:Content>
